package chat.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.xkh.xkh.MyApplication;
import com.xkh.xkh.R;

import java.util.ArrayList;
import java.util.List;

import model.User;

/**
 * 用户列表
 * Created by Administrator on 2016/3/29.
 */
public class UserAdapter extends BaseAdapter {

    private List<User> usersSubs = new ArrayList<User>();

    public void setUsersSubs(List<User> usersSubs) {
        this.usersSubs = usersSubs;
    }

    @Override
    public int getCount() {
        return usersSubs.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        convertView = View.inflate(MyApplication.share(), R.layout.item_user,null);
        TextView tv_user = (TextView) convertView.findViewById(R.id.id_item_tv_user);
        TextView tv_status = (TextView) convertView.findViewById(R.id.id_tv_state);

        User user = usersSubs.get(position);
        tv_user.setText(user.getUser_RealName());
        tv_status.setText(user.getUser_Status()?"在线":"离线");
        return convertView;
    }
}
